package com.dacd.pdf.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.dacd.adapter.ChooseFileAdapter;
import com.dacd.bean.FileListBean;
import com.dacd.pdf.R;

import java.util.ArrayList;
import java.util.List;

public class ChooseFileListActivity extends AppCompatActivity {

    private RecyclerView fileList;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_choose_file_list);
        fileList = (RecyclerView) findViewById(R.id.acfl_rv);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        fileList.addItemDecoration(new DividerItemDecoration(
                this, DividerItemDecoration.VERTICAL));
        fileList.setLayoutManager(layoutManager);
        initData();
    }

    private void initData() {
        FileListBean fileListBean1 = new FileListBean();
        fileListBean1.setFileName("新和建設Ａモデル");
        fileListBean1.setUpdateTime("最終更新日時：2019年 3月 30日 11時59分");
        FileListBean fileListBean2 = new FileListBean();
        fileListBean2.setFileName("新和建設Bモデル");
        fileListBean2.setUpdateTime("最終更新日時：2019年 3月 30日 11時59分");
        List<FileListBean> fileListBeans = new ArrayList<>();
        fileListBeans.add(fileListBean1);
        fileListBeans.add(fileListBean2);
        ChooseFileAdapter chooseFileAdapter = new ChooseFileAdapter(fileListBeans);
        fileList.setAdapter(chooseFileAdapter);
        chooseFileAdapter.setOnItemClickLitener(new ChooseFileAdapter.OnItemClickLitener() {
            @Override
            public void onItemClick(View view, int position) {
                Intent intent = new Intent(ChooseFileListActivity.this, MainActivity.class);
                startActivity(intent);
            }
        });
    }
}
